package com.literature.search.core.config.satoken;

/**
 * @Author: DangKong
 * @Date: 2023/3/1 22:46
 * @Description: 自定义Sa-Token权限认证接口扩展
 */


import cn.dev33.satoken.stp.StpInterface;
import cn.dev33.satoken.util.SaFoxUtil;
import com.literature.search.core.utils.sp.SpRoleUtil;
import org.springframework.stereotype.Component;

import java.util.List;
@Component
public class StpInterfaceImpl implements StpInterface {


    /** 返回一个账号所拥有的权限码集合  */
    @Override
    public List<String> getPermissionList(Object loginId, String loginType) {
        return null;
    }

    /**
     * 返回一个账号所拥有的角色标识集合
     */
    @Override
    public List<String> getRoleList(Object loginId, String loginType) {

        String id = SaFoxUtil.getValueByType(loginId, String.class); //获取用户id
        int roleId = SpRoleUtil.getRoleIdByUserId(id); //获取用户角色id
        String roleCode = RoleEnum.getMsgByCode(roleId);
        return SaFoxUtil.toList(roleCode);
    }

}
